//#define __FORCE_TRACE__
//#define __FORCE_DEBUG__
//#define __FORCE_INFO__
#define THIS_FILE "mission\init.sqf"
#include <tmf_constants.h>
#include <tmf_macros.h>
#include <modules\modules.hpp>

TLOG("Starting Mission Framework Initialisation");

// We set the debug level at the lowest as a standard to avoid flooding client computers
// Debug Levels:
// Server Info: 1
// Server Debug: 2
// Server Trace: 3
// Client Info (+full server): 6
// Client Debug (+full server): 7
// Client Trace (+full server): 8

INIT_DEBUG(0);

// Stores all the events used on the machine
if (isNil QGVAR(event_holder)) then {GVAR(event_holder) = "Land_HelipadEmpty_F" createVehicleLocal [0, 0, 0];};
// Stores all the variables of the mission framework
if (isNil QGVAR(mission_store)) then {GVAR(mission_store) = "Land_HelipadEmpty_F" createVehicleLocal [0, 0, 0];};
// Stores all the variables of the mission framework
if (isNil QGVAR(mission_variables)) then {GVAR(mission_variables) = "Land_HelipadEmpty_F" createVehicleLocal [0, 0, 0];};
// Used to send global messages to the players
if (isNil QGVAR(GlobalChatLogic)) then {GVAR(GlobalChatLogic) = "Logic" createVehicleLocal [0,0,0]};

EXECNOW(QPATH(modules\tmf_core\main.sqf));

_mission_name = getText (missionConfigFile >> "onLoadName");
if (isnil "_mission_name") then { _mission_name = "" };
if (_mission_name == "") then { _mission_name = localize "STR_MISSION_NAME" };
if (_mission_name == "") then { _mission_name = missionName };
_mission_desc = getText (missionConfigFile >> "onLoadMission");
if (isnil "_mission_desc") then { _mission_desc = "" };
if (_mission_desc == "") then { _mission_desc = localize "STR_MISSION_DESC" };
if (_mission_desc == "") then { _mission_desc = missionName };
_mission_author = getText (missionConfigFile >> "author");
if (isnil "_mission_author") then { _mission_author = "" };
if (_mission_author == "") then { _mission_author = "[V]Vétérans" };

_mission_description = [];
SETVAL(_mission_description,TMF_MD_ID,0);
SETVAL(_mission_description,TMF_MD_NAME,_mission_name);
SETVAL(_mission_description,TMF_MD_DESC,_mission_desc);
SETVAL(_mission_description,TMF_MD_VERSION,"1.2");
SETVAL(_mission_description,TMF_MD_AUTHOR,_mission_author);
[TMF_SERVER_INSTANCE_ID, TMF_HK_MISSION_DESC,_mission_description] call FFUNC(setMissionVar);

#ifdef ACV_EXPORT
EXECNOW(QPATH(modules\acv_export\init.sqf));
#endif

INFO("Ending Mission Framework Initialisation");
GVAR(LOADED) = true;